package org.project.controller2;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


import org.project.pojo.Appoiment;
import org.project.pojo.Comment;
import org.project.pojo.State;
import org.project.service.user.ImgsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

@Controller
@RequestMapping("/Otherfunction")
public class OtherfunctionController {
	@Resource
	private ImgsService imgsService;
	
	@RequestMapping("/insertcomment")
	@ResponseBody
	public State insertcomment(){
		HttpServletRequest req = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
         int i=0;
		String openid=req.getParameter("openid");
		
		String comment=req.getParameter("textcontent");
		
		
		System.out.println(comment+"AAAAAAAAAAAAAAAAAAAAAAAAA");
		System.out.println(openid);
		
		
		if(null!=openid&&null!=comment){
		Comment comment2=new Comment();
		comment2.setComment(comment);
		comment2.setOpenid(openid);
		i=imgsService.insertcomment(comment2);
		}
		State state=new State();
		state.setState(i);
		return  state;
	
	}
	
	
	
	@RequestMapping("/selectagreement")
	@ResponseBody
	public Appoiment selectagreement1(){
		
		Appoiment appoiment=imgsService.selectxieyi();
		return appoiment;
	}
	
	
	
	@RequestMapping("/selectnotice")
	@ResponseBody
	public Appoiment selectnotice(){
		Appoiment appoiment=imgsService.selectxuzhi();
		return appoiment;
	}
	
	
}
